/*wxBtVHTjruFsGR5nLWPsoOgeib0BPjtq0fKrsrIKiQ5fgE0ZcpyBjRpbcb/Grpwe*/
/*
 * @Author: xiahui 
 * @PageInfo: 列表查询实现 
 * @Date: 2019-01-15 09:15:33 
 * @Last Modified by: raoczh
 * @Last Modified time: 2020-11-30 09:46:12
 */
import { ajax } from 'nc-lightapp-front';
import { AREA, URL, PAGECODE } from '../../constance';
import {
	showHasQueryResultInfo,
	showNoQueryResultInfo,
	showRefreshInfo
} from '../../../../../scmpub/scmpub/pub/tool/messageUtil';
import { buttonControl } from '../viewControl/buttonControl';

export default function(props, queryInfo, isRefresh = false) {
	queryInfo.pageInfo = props.table.getTablePageInfo(AREA.listTableId); //分页信息;
	let data = {
		queryInfo,
		pageCode: PAGECODE.listPagecode, //页面编码
		currentTab: 'all' //当前页签
	};
	ajax({
		url: URL.query,
		data: data,
		success: (res) => {
			if (res.formulamsg && res.formulamsg instanceof Array && res.formulamsg.length > 0) {
				props.dealFormulamsg(
					res.formulamsg //参数一：返回的公式对象
				);
			}
			let rowsData = { rows: [] };
			if (res.data.currentGrid && res.data.currentGrid[AREA.listTableId]) {
				rowsData = res.data.currentGrid[AREA.listTableId];
			}
			if (rowsData.rows.length > 0) {
				isRefresh ? showRefreshInfo() : showHasQueryResultInfo(rowsData.rows.length);
				props.table.setAllTableData(AREA.listTableId, rowsData);
			} else {
				isRefresh ? showRefreshInfo() : showNoQueryResultInfo();
				props.table.setAllTableData(AREA.listTableId, { rows: [] });
			}
			// 按钮状态控制
			buttonControl.call(this, props);
		}
	});
}

/*wxBtVHTjruFsGR5nLWPsoOgeib0BPjtq0fKrsrIKiQ5fgE0ZcpyBjRpbcb/Grpwe*/